/**
 * @author harae Feng 
 * @date 2019-10-09 10:17:40 
 * @Last Modified by: harae Feng
 * @Last Modified time: 2019-10-09 10:22:57
 * @Describe 抖音-热门视频
 */


const fetch = require('../../util/fetchUtil').fetchRequest
const ResultAPI = require('../../routes/api/resultAPI')
const CatchHandle = require('../../routes/api/apicatch')


/**
 * 热门视频-实时
 */
async function videoHot(){
    let url = `https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/aweme/`
    let res = await fetch(url)
    let resJSON = await res.json()
    return resJSON
}

async function videoHotAPI(){
    try {
        let resJSON = await videoHot()
        if(resJSON.status_code === 0){
            return new ResultAPI(0, {}, resJSON)
        }else{
            return new ResultAPI(10003, {}, resJSON)
        }       
    } catch (error) {
        return CatchHandle(__dirname, __filename, error)
    }
}

module.exports = {
    videoHotAPI: videoHotAPI,
}